import request from '@/utils/request';

// 获取订单参数
export interface GetOrderParamsType {
    uId: string;
    userType: string;
    token: string;
    page: number;
    limit: number;
    select?: string;
    status?: string;
    startTime?: string;
    endTime?: string;
    sId?: string;
}

// 订单详情
export async function getOrder(data: GetOrderParamsType): Promise<any> {
	return request.post('/AgencyAdmin/getUserOrder', {
		data: {
			uId: data.uId,
			userType: data.userType,
			token: data.token,
			select: data.select,
			status: data.status,
			startTime: data.startTime,
			endTime: data.endTime,
			page: data.page,
			limit: data.limit,
			sId: data.sId,
		}
	})
}

// 充电线订单
export async function lineLeaseorder(data: LeaseorderParamsType): Promise<any> {
	return request.post('/AgencyAdmin/order/lineLeaseorder', {
		data: {
			...data,
		}
	})
}

// 充电线订单统计 
export async function lineLeaseorderTotal(data: LeaseorderParamsType): Promise<any> {
	return request.post('/AgencyAdmin/order/lineLeaseorderTotal', {
		data: {
			...data,
		}
	})
}

export interface LeaseorderParamsType {
	uId: string;
	userType: string;
	token: string;
	sid?: number | string;
	aid?: string;
	order_no?: string;
	status?: number | string;
	cabinetid?: string;
	wired_id?: string;
	start_starttime?: string;
	start_endtime?: string;
	end_starttime?: string;
	end_endtime?: string;
	page: number;
	limit: number;
}

// 充电宝订单
export async function leaseorder(data: LeaseorderParamsType): Promise<any> {
	return request.post('/AgencyAdmin/order/leaseorder', {
		data: {
			...data
		}
	})
}

// 充电宝订单统计 
export async function leaseorderTotal(data: LeaseorderParamsType): Promise<any> {
	return request.post('/AgencyAdmin/order/leaseorderTotal', {
		data: {
			...data,
		}
	})
}

export interface EndLeaseOrderParamsType {
	uId: string;
    userType: string;
	token: string;
	order_no: string;
	order_type: string | number;
	end_type: string | number;
	end_time: string;
}

// 结束订单 
export async function endLeaseOrder(data: EndLeaseOrderParamsType): Promise<any> {
	return request.post('/AgencyAdmin/endLeaseOrder', {
		data: {
			...data,
		}
	})
}

export interface LeaseOrderRefundParamsType {
	uId: string;
    userType: string;
	token: string;
	order_no: string;
	order_type: string | number;
	refund_amount: number; 
}

// 订单退款 
export async function leaseOrderRefund(data: LeaseOrderRefundParamsType): Promise<any> {
	return request.post('/AgencyAdmin/order/leaseOrderRefund', {
		data: {
			...data,
		}
	})
}


/**
 * 机柜/充电线导出参数
 * @param {Number} uId 	用户编号
 * @param {Number} userType 用户类型 1-代理，2-商户
 * @param {string} token 访问令牌
 * @param {string} device_id 设备编号
 * @param {string} sid 商户编号
 * @param {string} order_no 	订单编号
 * @param {Number} aid 代理编号
 * @param {string} wired_id 充电线编号
 * @param {Number} status 0-全部订单，1-租借中，2-已完成，3-订单超时
 * @param {string} start_starttime 租借开始时间起始范围 2020-12-21
 * @param {string} start_endtime 租借开始时间结束范围 2020-12-21
 * @param {string} pay_starttime 支付时间起始范围 2020-12-21
 * @param {string} pay_endtime 支付时间结束范围 2020-12-21
 * @param {string} end_starttime 租借结束时间起始范围 2020-12-21
 * @param {string} end_endtime 租借结束时间结束范围 2020-12-21
 */
export interface CabinetOrderExportParams {
	uId: number
	userType: number
	token: string
	sid: number | null
	order_no: string
	aid: number | null
	wired_id?: string
	cabinetid?: string
	status: number | string
	start_starttime: string
	start_endtime: string
	pay_starttime?: string
	pay_endtime?: string
	end_starttime?: string
	end_endtime?: string
}

/**
 * 导出充电宝订单
 * @param data 
 */
export async function cabineOrdertDataToCsvApi(data: CabinetOrderExportParams) {
    return request.post('/AgencyAdmin/order/leaseorderToCsv', {
        data: {
            ...data,
        }
    });
}

/**
 * 导出充电线订单
 * @param data 
 */
export async function powerLineOrderDataToCsvApi(data: CabinetOrderExportParams) {
    return request.post('/AgencyAdmin/order/lineLeaseorderToCsv', {
        data: {
            ...data,
        }
    });
}